package com.xiaode.controller.admin.statistics;

import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.ext.cors.EnableCORS;
import com.jfinal.kit.Ret;
import com.xiaode.common.anotation.Authority;
import com.xiaode.common.model.Admin;
import com.xiaode.util.apidoc.annotation.Api;
import com.xiaode.util.apidoc.annotation.ApiOper;
import com.xiaode.util.apidoc.annotation.ApiPara;

import java.util.Date;

@Path("/aStatistics")
@Api("首页统计")
@EnableCORS
public class StatisticsController extends Controller {
    @Inject
    private StatisticsService service;

    @ApiOper("月度之星")
    @Authority(description = "月度之星", permission = "admin:sAccount:monthStar", permissionParentName = "管理员模块", permissionName = "学生管理", type = 1)
    public void monthStar(
    		@ApiPara(value = "date", notes = "要查询的日期") Date date,
            @ApiPara(value = "gradeId", notes = "年级") Integer gradeId) throws Exception {
        Admin admin = getAttr("admin");
        Ret ret = service.monthStar(admin, date, gradeId);
        renderJson(ret);
    }

    @ApiOper("榜样排行")
    @Authority(description = "榜样排行", permission = "admin:aExample:exampleSort", permissionParentName = "榜样模块", permissionName = "重要他人管理", type = 1)
    public void exampleSort() throws Exception {
        Ret ret = service.exampleSort();
        renderJson(ret);
    }

    @ApiOper("积分排行")
    @Authority(description = "积分排行", permission = "admin:sAccount:scoreSort", permissionParentName = "管理员模块", permissionName = "学生管理", type = 1)
    public void scoreSort() throws Exception {
        Ret ret = service.scoreSort();
        renderJson(ret);
    }

    @ApiOper("登录情况分析")
    @Authority(description = "登录情况分析", permission = "admin:sAccount:loginSituationAnalysis", permissionParentName = "管理员模块", permissionName = "学生管理", type = 1)
    public void loginSituationAnalysis(@ApiPara(value = "gradeId", notes = "级别") Integer gradeId) throws Exception {
        Ret ret = service.loginSituationAnalysis(gradeId);
        renderJson(ret);
    }

    @ApiOper("学生在线情况分析")
    @Authority(description = "学生在线情况分析", permission = "admin:sAccount:stuOnlineAnalysis", permissionParentName = "管理员模块", permissionName = "学生管理", type = 1)
    public void stuOnlineAnalysis(@ApiPara(value = "gradeId", notes = "级别") Integer gradeId) throws Exception {
        Ret ret = service.stuOnlineAnalysis(gradeId);
        renderJson(ret);
    }

    @ApiOper("教师在线情况分析")
    @Authority(description = "教师在线情况分析", permission = "admin:aAccount:teaOnlineAnalysis", permissionParentName = "管理员模块", permissionName = "教师管理", type = 1)
    public void teaOnlineAnalysis(@ApiPara(value = "gradeId", notes = "级别") Integer gradeId) throws Exception {
        Ret ret = service.teaOnlineAnalysis(gradeId);
        renderJson(ret);
    }

    @ApiOper("在线时间段分析")
    @Authority(description = "在线时间段分析", permission = "admin:aAccount:onlineSegement", permissionParentName = "管理员模块", permissionName = "教师管理", type = 1)
    public void onlineSegement(@ApiPara(value = "gradeId", notes = "级别") Integer gradeId)throws Exception{
        Ret ret = service.onlineSegement(gradeId);
        renderJson(ret);
    }

    @ApiOper("模块使用时长分析")
    @Authority(description = "模块使用时长分析", permission = "admin:sAccount:moduleUseDuration", permissionParentName = "管理员模块", permissionName = "学生管理", type = 1)
    public void moduleUseDuration(@ApiPara(value = "gradeId", notes = "级别") Integer gradeId)throws Exception{
        Ret ret = service.moduleUseDuration(gradeId);
        renderJson(ret);
    }

}
